<template>
	<view>
		<view>
			<table-title content="维修服务办理表详情"></table-title>
			<view class="record-id">单号：{{processNo}}</view>
			<view class="in-center">
				<small-title content="基本资料"></small-title>
				<view class="state-bar">
					<view class="state-msg">{{state}}</view>
				</view>
			</view>
			<view class="item-table">
				<view-item name="租户名称" :value="userMsg.userCompany"></view-item>
				<view-item name="楼盘" :value="userMsg.userBuilding"></view-item>
				<view-item name="楼层" :value="userMsg.userFloor"></view-item>
				<view-item name="房间号" :value="userMsg.userRoom" :isLast="true"></view-item>
			</view>
			<view>
				<small-title content="区域"></small-title>
				<radio-group :disabled="!(state === '待申请' || state === '已驳回')" class="radiogroup-style">
					<view @click="chooseWork" class="first-radio">
						<radio :disabled="!(state === '待申请' || state === '已驳回')" :checked="workChecked" color="#FF0000"></radio>
						<view >办公区域</view>
					</view>
					<view  @click="choosePublic" class="second-radio">
						<radio :disabled="!(state === '待申请' || state === '已驳回')" :checked="publicChecked" color="#FF0000"></radio>
						<view>公共区域</view>
					</view>
				</radio-group>
			</view>
			<view>
				<small-title content="问题描述"></small-title>
				<textarea class="textarea-style" maxlength="-1" :disabled="!(state === '待申请' || state === '已驳回')" :value="problemContent" @input="inputDetial"></textarea>
			</view>
			<small-title content="上传图片"></small-title>
			<view class="img-repair">
				<uni-file-picker 
				    v-model="imageValue"  
				    file-mediatype="image"
				    mode="grid"
				    file-extname="png,jpg"
				    :limit="3"
					ref="files"
					:auto-upload="false"
					:readonly="true"
				/>
			</view>
			<view v-if="status > 0 && status < 7">
				<small-title :isNeed="true" content="选择工程负责人"></small-title>
				<view class="small-title">
					<select-lay :disabled="!(status==1 || status==2)" :value="tval" name="name" :options="datalist" @selectitem="selectitem"></select-lay>
				</view>
			</view>
			<view v-if="status > 3 && status < 7">
				<small-title content="已添加的协同人员"></small-title>
				<view class="small-title">
					<yealuo-select the-style="margin: 20upx auto;font-size: 46upx;"
					        :value=afforceUserListName 
					        placeholder='可添加协同人员' 
					        :binData="engUserList"
					        checkType="radio"
					        overflow="hide"
					        @getBackVal="getBackVal"
					        :selectIco="((status === 4) && (parseInt(curSpecialEng) == parseInt(currentId) || (userRightDetail.decoration.engVerRight)))"
							:disabled="!((status === 4) && (parseInt(curSpecialEng) == parseInt(currentId) || (userRightDetail.decoration.engVerRight)))"
					        >
					</yealuo-select>
				</view>
				<view v-if="status == 4 && (parseInt(curSpecialEng) == parseInt(currentId) || (userRightDetail.decoration.engVerRight))">
					<button v-if="status == 4 && userRightDetail.decoration.engCommRight" class="add-button-afford" :disabled="addUserFlag" @click="afforce()">确认更改协同人员</button>
				</view>
			</view>
			<small-title :isNeed="true" v-if="status >= 2 && status < 7" content="维修清单"></small-title>
			<view v-if="status >= 2 && status < 7" style="margin-left: 20rpx;margin-right: 20rpx;">
				<uni-table :newMinWidth="(status===2 && userRightDetail.repair.engCommRight)?200:0" border stripe emptyText="暂无更多数据" >
				    <!-- 表头行 -->
				    <uni-tr>
						<uni-th style="width: 50rpx;" align="center">序号</uni-th>
				        <uni-th style="width: 50rpx;" align="center">维修项目</uni-th>
				        <uni-th style="width: 50rpx;" align="center">金额</uni-th>
				        <uni-th style="width: 50rpx;" align="center">负责人</uni-th>
						<uni-th v-if="status===2 && userRightDetail.repair.engCommRight"></uni-th>
				    </uni-tr>
				    <!-- 表格数据行 -->
				    <uni-tr v-for="(item,index) in goodList" :key="index">
				        <uni-td  align="center">
							<view style="width: 60rpx;">{{index + 1}}</view>
						</uni-td>
				        <uni-td>
							<view style="width: 280rpx;">
								<input :disabled="!(status===2 && userRightDetail.repair.engCommRight)" type="text" v-model="item.goodsName" placeholder="请输入项目名称" />
							</view>
						</uni-td>
				        <uni-td>
							<view style="width: 100rpx;">
								<input :disabled="!(status===2 && userRightDetail.repair.engCommRight)" type="number" v-model="item.amount" placeholder="请输入" @input="check(index)" @blur="calPrice"/>
							</view>
						</uni-td>
						<uni-td>
							<view style="width: 100rpx;">
								<input :disabled="!(status===2 && userRightDetail.repair.engCommRight)" type="text" v-model="item.unit" placeholder="" />
							</view>
						</uni-td>
						<uni-td v-if="status===2 && userRightDetail.repair.engCommRight">
							<view v-if="status===2 && userRightDetail.repair.engCommRight" style="width: 100rpx;">
								<button style="width: 150rpx;margin-left: 0rpx;font-size: 28rpx;" @click="deleteGoods(index)">删除</button>
							</view>
						</uni-td>
				    </uni-tr>
				</uni-table>
			</view>
			<view v-if="status >= 2 && status < 7" class="small-title">费用合计：{{this.allPrice}} 元</view>
			<button v-if="status===2 && userRightDetail.repair.engCommRight" class="add-button" @click="addGoods()">添加项+</button>
			<small-title v-if="status >= 0" content="处理进度"></small-title>
			<proccess-bar v-if="processFlag" :proccessList="proccessListDefult"></proccess-bar>
			<view v-if="status===1 && userRightDetail.repair.opeCommRight" class="mix-button">
				<view class="left-part">
					<button class="left-button" @click="allot">发起指派</button>
				</view>
				<view class="right-part">
					<button class="right-button" @click="back">返回</button>
				</view>
			</view>
			<view v-if="status===2 && userRightDetail.repair.engCommRight" class="mix-button">
				<view class="left-part">
					<button class="left-button" @click="confirmRepairBegin">确认维修内容</button>
				</view>
				<view class="right-part">
					<button class="right-button" @click="changeWaiter">转单</button>
				</view>
			</view>
			<view v-if="status===4 && userRightDetail.repair.engCommRight" class="mix-button">
				<view class="left-part">
					<button class="left-button" @click="confirmRepairEnd">施工完毕</button>
				</view>
				<view class="right-part">
					<button class="right-button" @click="back">返回</button>
				</view>
			</view>
			<view v-if="status===0 && userRightDetail.repair.opeCommRight" class="mix-button">
				<view class="left-part">
					<button class="left-button" @click="verify(0)">审核通过</button>
				</view>
				<view class="right-part">
					<button class="right-button" @click="open">驳回</button>
				</view>
			</view>
			<view style="height: 200rpx;"></view>
		</view>
		<uni-popup ref="popup" type="dialog">
		    <uni-popup-dialog mode="input" message="成功消息" title="请输入驳回理由" :duration="2000" :before-close="true" @close="close" @confirm="confirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>		

<script>
	import {
		ONLINE_SERVER_ADDRESS_BASE_2
	} from "../../..//util/network.js"
	import {
		myUploadFile,
		myDownloadFile,
		syncGetOrder,
		syncGetSysUsr,
		syncGetSysUsrInfo,
	} from "../../..//util/network.js"
	import {
		processHistoryList
	} from "../../../util/common.js"
	export default{
		data() {
			return {
				processFlag:false,
				userRightDetail:'',
				token:'',
				recordId:'',
				processNo:'待分配',
				state: '',
				status: -1,
				publicChecked: true,
				workChecked: false,
				problemContent:'',
				areaType: -1,
				imageUrl: ['../../../static/add-logo.svg','../../../static/add-logo.svg','../../../static/add-logo.svg',
				           0,0,0],
				imageValue:[],
				allPrice: 0,
				nopassReasons:'审核通过',
				userMsg:{'userName':'','userPhone':'','userCompany':'','userBuilding':'',
					'userFloor':'','userRoom':''},
				goodList:[{'goodsName':'','amount':'','unit':''}],
				proccessList:[
					{'type':'firstCanvas','commentMsg':'发起申请','time':'2021-01-01 01:01:11'},
					{'type':'middleCanvas','commentMsg':'受理','time':'2020-02-02 02:02:22'},
					{'type':'lastCanvas','commentMsg':'办结','time':'2020-03-03 03:33:33'}
				],
				proccessListDefult:[],
				datalist: [],
				tval: "value2",
				curSpecialEng:-1,
				engUserList: [
					// {id: 1, value: '选项1'},
					// {id: 2, value: '选项2'},
					// {id: 3, value: '选项3'},
					// {id: 4, value: '选项4'},
					// {id: 5, value: '选项5'},
					// {id: 6, value: '这是6'},
					// {id: 7, value: '这是7'},
					// {id: 8, value: '这是8'},
					// {id: 10, value: '这是9'},
					// {id: 11, value: '这是10'},
				],
				afforceUserList:[],
				afforceUserListName:'',
				addUserFlag:false,
				previewUrl:ONLINE_SERVER_ADDRESS_BASE_2 + '/file/preview/'
			}
		},
		methods: {

			check: function(index) {
				//正则表达试
				let temp = (this.goodList[index].amount.match(/^\d*(\.?\d{0,2})/g)[0]) || null
				//重新赋值给input
				this.$nextTick(() => {
					this.goodList[index].amount= temp
				})
			},
			getBackVal:function(e){
				console.log(e)
				this.afforceUserList = []
				e.split(",").forEach(item => {
					if(item != ''){
						this.afforceUserList.push(+(item).split('|')[1])
					}
				})
			},
			open() {
				this.$refs.popup.open()
			},
			/**
			 * 点击取消按钮触发
			 * @param {Object} done
			 */
			close() {
				// TODO 做一些其他的事情，before-close 为true的情况下，手动执行 close 才会关闭对话框
				// ...
				this.$refs.popup.close()
			},
			/**
			 * 点击确认按钮触发
			 * @param {Object} done
			 * @param {Object} value
			 */
			confirm(value) {
				this.$refs.popup.close()
				if(value == ""){
					uni.showModal({
						content:'理由不能为空',
						showCancel:false
					});
					this.$refs.popup.close()
				}else{
					if(this.userRightDetail.knotCommission.primeAuth == 1){
						this.nopassReasons = "运营主管已驳回，原因：" + value
					}else{
						this.nopassReasons = "楼层管家已驳回，原因：" + value
					}
					this.verify(1)
					// TODO 做一些其他的事情，手动执行 close 才会关闭对话框
					// ...
					this.$refs.popup.close()
				}
			},
			selectitem(index, item) {
				if (index >= 0) {
					this.tval = item.value;
				} else {
					this.tval = ""
				}
			},
			inputDetial(e){
				this.problemContent = e.detail.value
			},
			/*
			功能：添加一行放行物品信息
			参数：无
			*/
			addGoods(){
				console.log('点击了添加')
				if(this.goodList == null){
					this.goodList = []
				}
				this.goodList.push({'goodsName':'','amount':'','unit':''})
			},
			deleteGoods(index){
				if(this.goodList.length <= 1){
					let temp = {'goodsName':'','amount':'','unit':''}
					this.$set(this.goodList,index,temp)
					this.calPrice()
					return
				}
				this.goodList.splice(index,1)
				this.calPrice()
			},
			choosePublic(){
				if(this.state === '待申请' || this.state === '已驳回'){
					this.workChecked = false
					this.publicChecked = true
					console.log(this.workChecked)
				}
			},
			chooseWork(){
				if(this.state === '待申请' || this.state === '已驳回'){
					this.workChecked = true
					this.publicChecked = false
				}
			},
			/*
			功能：支付截图点击事件触发修改或预览照片，如果是待申请 则点击修改照片，否则则是预览
			参数：无
			*/
			chooseImage(index){
				console.log("ceshi",index)
				uni.previewImage({
					current: 0,
					urls: [this.imageUrl[index]]
				})
			},
			// async loadImg(chargeFileId){
			// 	// let _this = this
			// 	const res = await uni.downloadFile({
			// 		url:`${ONLINE_SERVER_ADDRESS_BASE_2}/file/download/` + chargeFileId,
			// 		header: {
			// 			'Authorization': this.token,
			// 		},
			// 	})
			// 	return new Promise((resolve, reject) => {
			// 	        resolve(res[1].tempFilePath)
			// 	})
			// },
			calPrice(){
				this.allPrice = 0
				for (var i = 0; i < this.goodList.length; i++) {
					if(this.goodList[i].amount < 0){
						this.goodList[i].amount = 0
					}
					this.allPrice += Number(this.goodList[i].amount)
				}
			},
			allot(){
				console.log("[info]","维修管家指派：" + this.recordId)
				if(!(parseInt(this.tval) > 0)){
					uni.showModal({
						content:'请选择工程负责人',
						showCancel:false
					});
					return -1
				}
				if(this.userRightDetail.knotCommission.primeAuth == 1){
					this.nopassReasons = "运营主管已指派工程负责人"
				}else{
					this.nopassReasons = "楼层管家已指派工程负责人"
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/allot/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						allotType:0,
						// userIds:JSON.stringify([parseInt(this.tval)]),
						userIds:[parseInt(this.tval)],
						commentMsg: this.nopassReasons,                       //操作信息
					},
					method:'POST',
					success: function (res) {
						console.log("维修管家指派调用",res.data)
						if(res.data.code == 200){
							uni.navigateBack()
						}
					},
					fail: (res) => {
						console.log("维修管家指派调用失败")
					}
				})
			},
			changeWaiter(){
				if(parseInt(this.tval) == parseInt(this.currentId)){
					uni.showModal({
						content:'当前选择的工程人员已是负责人，无法转单',
						showCancel:false
					});
					return -1
				}
				if(this.userRightDetail.repair.primeAuth == 7){
					this.nopassReasons = "工程主管已转单"
				}else{
					this.nopassReasons = "工程专员已转单"
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/change-waiter/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						userId:parseInt(this.tval),
						commentMsg: '工程已转单',                       //操作信息
					},
					method:'POST',
					success: function (res) {
						if(res.data.code == 200){
							uni.navigateBack()
						}
					},
					fail: (res) => {
						console.log("工程转单调用失败")
					}
				})
			},
			afforce(){
				if(!(parseInt(this.curSpecialEng) == parseInt(this.currentId) || (this.userRightDetail.decoration.engVerRight))){
					uni.showModal({
						content:'非工程负责人或工程主管，无法添加协从',
						showCancel:false
					});
					return -1
				}
				for (var i = 0; i < this.afforceUserList.length; i++) {
					if(this.afforceUserList[i] == this.currentId){
						uni.showModal({
							content:'无法添加自己为协从人员',
							showCancel:false
						});
						return -1
					}
					if(this.afforceUserList[i] == parseInt(this.curSpecialEng)){
						uni.showModal({
							content:'无法添加工程负责人为协从人员',
							showCancel:false
						});
						return -1
					}
				}
				this.addUserFlag = true
				console.log("[info]","添加协同人员：" + this.afforceUserList)
				let _this = this
				if(this.userRightDetail.repair.primeAuth == 7){
					this.nopassReasons = "工程主管更改了协同人员"
				}else{
					this.nopassReasons = "工程专员更改了协同人员"
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/allot/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						allotType:1,
						userIds:this.afforceUserList,
						commentMsg: this.nopassReasons,                       //操作信息
					},
					method:'POST',
					success: function (res) {
						_this.addUserFlag = false
						if(res.data.code == 200){
							uni.showModal({
								content:'更改成功',
								showCancel:false
							});
						}
					},
					fail: (res) => {
						_this.addUserFlag = false
						console.log("新增协同调用失败")
					},
				})
			},
			verify(status){
				console.log("[info]","审核维修内容：" + this.recordId)
				if(status == 0){
					if(this.userRightDetail.knotCommission.primeAuth == 1){
						this.nopassReasons = "运营主管审核通过"
					}else{
						this.nopassReasons = "楼层管家审核通过"
					}
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/verify/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						nopassReasons:this.nopassReasons,
						verifyResult:status,
						commentMsg: this.nopassReasons,                       //操作信息
					},
					method:'POST',
					success: function (res) {
						if(res.data.code == 200){
							uni.navigateBack()
						}
					},
					fail: (res) => {
						console.log("审核维修内容调用失败")
					}
				})
			},
			confirmRepairBegin(){
				if(this.checkPara() == -1){
					return -1
				}
				if(!(parseInt(this.curSpecialEng) == parseInt(this.currentId))){
					this.nopassReasons = '工程主管已确认维修事项'
				}else{
					this.nopassReasons = '工程专员已确认维修事项'
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/confirm/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						goodList:JSON.stringify(this.goodList),
						price:this.allPrice,
						commentMsg: this.nopassReasons                       //操作信息
					},
					method:'POST',
					success: function (res) {
						if(res.data.code == 200){
							uni.navigateBack()
						}
					},
					fail: (res) => {
						console.log("工程确认调用失败")
					}
				})
			},
			checkPara(){
				let flag = 0
				if(this.goodList.length == 0){
					uni.showModal({
						content:'请添加维修项',
						showCancel:false
					})
					flag = -1
					return flag
				}
				for(var i = 0; i < this.goodList.length; i++){
					console.log(item)
					this.goodList[i].goodsName = this.goodList[i].goodsName.trim()
					this.goodList[i].unit = this.goodList[i].unit.trim()
					let item = this.goodList[i]
					if(item.goodsName == ""){
						uni.showModal({
							content:'维修项名称不能为空',
							showCancel:false
						})
						flag = -1
						break
					}
					if(item.amount == "" || item.amount < 0){
						uni.showModal({
							content:'请输入有效维修项价格',
							showCancel:false
						})
						flag = -1
						break
					}
				}
				return flag
			},
			confirmRepairEnd(){
				if(!(parseInt(this.curSpecialEng) == parseInt(this.currentId))){
					if(this.userRightDetail.repair.primeAuth == 7){
						this.nopassReasons = "工程主管已确认施工完毕"
					}else{
						uni.showModal({
							content:'协同人员无法确认施工完毕',
							showCancel:false
						})
						this.nopassReasons = "协同人员无法确认施工完毕"
						return -1
					}
				}else{
					this.nopassReasons = '工程专员已确认施工完毕'
				}
				uni.request({
					url:`${ONLINE_SERVER_ADDRESS_BASE_2}/repair/engineer-finish/` + this.recordId,
					header: {
						'Authorization': this.token,
					},
					data: {
						commentMsg: this.nopassReasons                       //操作信息
					},
					method:'POST',
					success: function (res) {
						if(res.data.code == 200){
							uni.navigateBack()
						}
					},
					fail: (res) => {
						console.log("工程确认调用失败")
					}
				})
			},
			getOrder(){
				let a = syncGetOrder("repair/show/" + this.recordId)
				 a.then((res)=>{
					 console.log("异步",res)
					 if(res.data.code == 200){
						 this.status = parseInt(res.data.data.auditStatus)
						 switch(this.status) {
						 	 case 0:
						 		this.state = "待管家审核"
						 		break;
						 	 case 1:
						 		this.state = "待指派工程"
						 		break;
						 	 case 2:
						 		this.state = "待工程确认"
						 		break;
						 	 case 3:
						 		this.state = "待确认支付"
						 		break;
						 	 case 4:
						 		this.state = "待施工完毕"
						 		break;
						 	 case 5:
						 		this.state = "待验收结果"
						 		break;
						 	 case 6:
						 		this.state = "已完成维修"
						 		break;
						 	 case 7:
						 		this.state = "管家已驳回"
						 		break;
						 	 case 8:
						 		this.state = "已取消工单"
						 		break;
						 	 default:
						 	    this.status = -1
						 		this.state = "待申请"
						 } 
						 if(res.data.data.areaType == 0){
						 	 this.workChecked = true
						 	 this.publicChecked = false
						 }else{
						 	 this.workChecked = false
						 	 this.publicChecked = true
						 }
						 this.userMsg.userCompany = res.data.data.createUserInfo.name
						 this.userMsg.userBuilding = res.data.data.createUserInfo.title
						 this.userMsg.userFloor = res.data.data.createUserInfo.floor
						 this.userMsg.userRoom = res.data.data.createUserInfo.houseNumber
						 this.problemContent = res.data.data.description
						 this.processNo = res.data.data.processOn
						 try{
							 var photoArray = res.data.data.photo.split(",")
							 this.imageValue = []
							 for (var i = 0; i < photoArray.length; i++) {
								let index = i
								let temp = {}
								temp.url = this.previewUrl + photoArray[i]
								temp.id = parseInt(photoArray[i])
								this.imageValue.push(temp)
							 }
						 }catch(e){
						 	//TODO handle the exception

						 }
						 this.goodList = JSON.parse(res.data.data.detail)
						 if(this.status == 2){
							 this.goodList = [{'goodsName':'','amount':'','unit':''}]
						 }
						 this.allPrice = res.data.data.price
						 this.proccessListDefult = processHistoryList(res.data.data.processDetail)
						 this.processFlag = true
						 if(res.data.data.jointIds == null){
							 this.afforceUserList = []
						 }else{
							 this.afforceUserList.push(+res.data.data.jointIds)
						 }
						 this.$forceUpdate()
						 if(this.status > 1 && this.status < 7){ //如果是已指派过的状态 则按id查询工程专员
						 	let b = syncGetSysUsrInfo("systemuser/show/" + parseInt(res.data.data.engineerSpecialistId));
							// let b = syncGetSysUsrInfo("systemuser/show/10209");
						 	b.then((v)=>{
						 		 if(v.data.code == 200){
									 let temp = {label: "",value: ""}
									 temp.label = v.data.data.name
									 temp.value = res.data.data.engineerSpecialistId
									 this.curSpecialEng = res.data.data.engineerSpecialistId
									 if(this.status == 2){ //如果是工程负责人状态 则按区域查询工程专员
										let a = syncGetSysUsr("systemuser/area-auth/users", this.areaId, 8);
									 	a.then((res)=>{
									 		 if(res.data.code == 200){
									 			let resList = res.data.data.systemUserList
									 			resList.forEach((item,key) => {
									 				let temp2 = {label: "",value: ""}
									 				temp2.label = item.name
									 				temp2.value = item.id.toString()
													this.datalist.push(temp2)
									 			});
									 			this.$forceUpdate()
									 		}
									 	})
									 }else{
										 this.datalist.push(temp)
									 }
									// this.datalist.push(temp)
						 			this.tval = temp.value
						 			this.$forceUpdate()
						 		}
						 	})
						 }
						 if(this.status == 1){ //如果是待指派状态 则按区域查询工程专员
						 	let a = syncGetSysUsr("systemuser/area-auth/users", this.areaId, 8);
						 	a.then((res)=>{
						 		 if(res.data.code == 200){
						 			let resList = res.data.data.systemUserList
						 			resList.forEach((item,key) => {
						 				let temp = {label: "",value: ""}
						 				temp.label = item.name
						 				temp.value = item.id.toString()
						 				this.datalist.push(temp)
						 			});
						 			this.$forceUpdate()
						 		}
						 	})
						 }
						 if(this.status >= 4 && this.status < 7){ //如果是施工中状态，可添加协同人员
						 	let a = syncGetSysUsr("systemuser/area-auth/users", this.areaId, 8);
						 	a.then((res)=>{
						 		 if(res.data.code == 200){
						 			let resList = res.data.data.systemUserList
						 			resList.forEach((item,key) => {
						 				let temp = {id: "",value: ""}
						 				temp.value = item.name
						 				temp.id = item.id
						 				this.engUserList.push(temp)
						 			});
									if(this.status >= 4 && this.status < 7){ //如果是施工中及之后的状态，可添加协同人员
										this.afforceUserListName = '';
										this.afforceUserList.forEach(item => {
											this.engUserList.forEach(item2 => {
												if(item2.id == item){
													this.afforceUserListName+=(item2.value + ',')
												}
											})
										})
									}
						 			this.$forceUpdate()
						 		}
						 	})
						 }
					}
				})
			},
			back(){
				uni.navigateBack()
			}
		},
		onLoad(option) {
			//传入单号
			if(uni.getStorageSync('userinfo') != null){
				this.userRightDetail = uni.getStorageSync("userRight")
				let info = uni.getStorageSync("currentUser")
				this.currentId = info.id
				this.areaId = info.area_id
				this.recordId = option.id
				this.token = uni.getStorageSync('token')
				// this.state = "待申请"
			}else{
				uni.navigateTo('../../login/login')
			}
		},
		mounted() {
			//如果是新建表单则不查询
			if(this.state != '待申请'){
				this.getOrder()
			}
			//根据当前页面维修清单计算金额
			for (var i = 0; i < this.goodList.length; i++) {
				this.allPrice += Number(this.goodList[i].amount)
			}
		}
	}
</script>

<style>
	page{
		background-color: #ffffff
	}
	.record-id{
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
	}
	.state-bar{
		align-items: center;
		color: #FFFFFF;
		background-color: #DD524D;
		width: 260rpx;
		justify-content: flex-end;
		margin-left: auto;
		margin-right: 50rpx;
		font-size: 30rpx;
		border-radius: 50rpx;
		height: 50rpx;
	}
	.state-msg{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.in-center{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.item-table{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.radiogroup-style{
		width: 650rpx;
		height: 100rpx;
		background-color: #FFFFFF;
		display: flex;
		margin-left: 50rpx;
		justify-content: center;
		border: solid 1rpx #C0C0C0;
	}
	.textarea-style{
		display: flex;
		justify-content: center;
		width: 650rpx;
		height: 300rpx;
		margin-left: 50rpx;
		background-color: #FFFFFF;
		border: solid 1rpx #C0C0C0;
	}
	.first-radio{
		display: flex;
		height: 100rpx;
		width: 300rpx;
		align-items: center;
	}
	.second-radio{
		display: flex;
		height: 100rpx;
		align-items: center;
		margin-left: 50rpx;
	}
	.mix-button{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.left-part{
		float: right;
	}
	.right-part{
		float: left;
	}
	.left-button{
		background-color: #FF0000;
		border-radius: 50rpx 0 0 50rpx;
		color: #FFFFFF;
		width: 300rpx;
		font-size: 30rpx;
	}
	.right-button{
		background-color: #0000FF;
		border-radius: 0 50rpx 50rpx 0;
		color: #FFFFFF;
		width: 300rpx;
		font-size: 30rpx;
	}
	.picture-block{
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-left: 60rpx;
	}
	.picture-part{
		display: flex;
		margin: 0 0 50rpx 0;
		font-size: 100rpx;
		font-weight: 200;
		align-items: center;
		justify-content: center;	
		width: 170rpx;
		height: 170rpx;
		border: dashed 1rpx #000000;
	}
	.picture-style{
		width: 170rpx;
		height: 170rpx;
		margin: 0 0 10rpx 0rpx;
	}
	.add-button {
		border-width: 0px;
		align-items: center;
		justify-content: center;
		margin: 30rpx 0 40rpx 250rpx;
		height: 50rpx;
		width: 250rpx;
		display: flex;
		color: #22B242;
	}
	.add-button-afford {
		border-width: 0px;
		align-items: center;
		justify-content: center;
		/* margin: 30rpx 0 40rpx 250rpx; */
		margin-top: 30rpx;
		margin-bottom: 30rpx;
		height: 50rpx;
		width: 450rpx;
		display: flex;
		color: #22B242;
	}
	.payway-style {
		display: flex;
		flex-direction: column;
		width: 650rpx;
	}
	.payway-first-radio {
		height: 100rpx;
		display: flex;
		align-items: center;
		background-color: #FFFFFF;
		padding-left: 25rpx;
		border: solid 0rpx #C8C7CC;
		border-bottom: none;
		border-right: none;
	}
	.payway-second-radio {
		height: 100rpx;
		display: flex;
		align-items: center;
		background-color: #FFFFFF;
		padding-left: 25rpx;
		border: solid 0rpx #C8C7CC;
		border-right: none;
		width: 50rpx;
	}
	.payway-choice {
		display: flex;
		align-items: center;
		background-color: #FFFFFF;
		border: solid 0rpx #C8C7CC;
		width: 600rpx;
		border-left: none;
	}
	.payway-logo {
		width: 50rpx;
		height: 50rpx;
		margin: 0 25rpx 0 25rpx;
	}
	.small-title{
		margin: 20rpx 0 20rpx 50rpx;
		width: 87%;
	}
	.img-repair{
		margin: 20rpx 50rpx 20rpx 50rpx;
	}
</style>
